using System;
using System.Diagnostics;
using System.IO;
using System.Collections.Generic;
using org.tmatesoft.svn.core.wc;
using org.tmatesoft.svn.core;

namespace Subsync.Core.Subversion
{
	/// <summary>
	/// Author: Juin Min
	/// </summary>
	public class SVNRevert : CommandBase
	{
		private java.io.File[] filepath;

		public SVNRevert (string[] revertpaths)
		{
			Debug.WriteLine("SVN Revert constructor");
			int n = revertpaths.Length;
			this.filepath = new java.io.File[n];

			for (int i=0;i<n;i++)
				filepath[i] = new java.io.File(revertpaths[i]);
		}
		
		public override void Execute()
		{
			Debug.WriteLine("SVN Revert Execution");
					
			// Setup library
			Tools.SetupLibrary();
			
			// Setup clients
			SVNClientManager cm = SVNClientManager.newInstance();
			SVNWCClient wcclient = cm.getWCClient();
			
			try
            {	
				wcclient.doRevert(filepath, SVNDepth.INFINITY, null);
			}
            catch (SVNException expt)
            {
				throw new SVNExecuteException(expt.getMessage());
			}
            catch	(SVNExecuteException expt)
            {
				throw expt;
			}		
		}
	}
}
